﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web.UI;
using System.Web.Configuration;
using System.ComponentModel;
using Beetle.Web.Extensions;

namespace Beetle.Web.UI.WebControls
{
    /// <summary>
    /// 数据绑定面板
    /// </summary>
    /// <!-- 作者:韦腾  时间:2010年03月01日 -->
    public class DataPanel : System.Web.UI.WebControls.Panel, IDataItemContainer, IEditStatus
    {
        #region IDataItemContainer 成员

        private object dataItem = null;
        private int dataItemIndex = 0;
        private int displayIndex = 0;
        public object DataItem
        {
            get
            {
                return this.dataItem;
            }
            set
            {
                this.dataItem = value;
            }
        }

        public int DataItemIndex
        {
            get
            {
                return this.dataItemIndex;
            }
        }

        public int DisplayIndex
        {
            get
            {
                return this.displayIndex;
            }
        }

        #endregion

        #region IEditStatus 成员

        public bool IsEditMode
        {
            get
            {
                object o = ViewState["IsEditMode"];
                return o != null ? (bool)o : true;
            }

            set
            {
                ViewState["IsEditMode"] = value;
            }
        }

        private bool? _InternalEditMode = null;

        [Browsable(false)]
        [EditorBrowsable(EditorBrowsableState.Never)]
        public bool? InternalEditMode
        {
            get
            {
                return this._InternalEditMode;
            }
        }

        public void SetInternalEditModeValue(bool? b)
        {
            this._InternalEditMode = b;
        }

        public bool CheckEditMode()
        {
            if (!this.IsEditMode)
            {
                return false;
            }

            return this.GetEditMode();
        }
        #endregion
    }
}
